/**
* @Author luof
* @Date 2024/4/28 11:25
* @Description:
*/
<template>
  <el-menu
      class="el-menu-vertical-demo"
      :collapse="isCollapse"
      @open="handleOpen"
      @close="handleClose"
      text-color="#4D5259"
      router
  >
    <h3 @click="handleChangeCollapse()">{{ isCollapse ? "后台" : "后台管理" }}</h3>
    <el-menu-item index="/admin/index">
      <el-icon><HomeFilled /></el-icon>
      <span>后台首页</span>
    </el-menu-item>
    <el-menu-item index="/admin/web">
      <el-icon><Tools /></el-icon>
      <span>网站配置</span>
    </el-menu-item>
    <el-menu-item index="/admin/userlist">
      <el-icon><UserFilled /></el-icon>
      <span>用户管理</span>
    </el-menu-item>
    <el-menu-item index="/admin/sign">
      <el-icon><Edit /></el-icon>
      <span>签名管理</span>
    </el-menu-item>
    <el-menu-item index="/admin/meallist">
      <el-icon><Histogram /></el-icon>
      <span>套餐管理</span>
    </el-menu-item>
    <el-menu-item index="/admin/paylist">
      <el-icon><List /></el-icon>
      <span>账单记录</span>
    </el-menu-item>
    <el-menu-item index="/admin/smslist">
      <el-icon><Message /></el-icon>
      <span>短信列表</span>
    </el-menu-item>
<!--    <el-menu-item index="/admin/center" @click="refreshRoute('/admin/center')">-->
<!--      <el-icon>-->
<!--        <UserFilled/>-->
<!--      </el-icon>-->
<!--      <span slot="title">个人中心</span>-->
<!--    </el-menu-item>-->
    <el-menu-item @click="handleExit">
      <el-icon><SwitchButton/></el-icon>
      <span slot="title">退出登录</span>
    </el-menu-item>
  </el-menu>
</template>

<script lang="ts" setup>
import {computed, ComputedRef, watch} from 'vue'
import {useStore} from "vuex";
import {useRoute, useRouter} from "vue-router";
import {Edit, Histogram, HomeFilled, List, Message, SwitchButton, Tools, UserFilled} from "@element-plus/icons-vue";

const store = useStore()
const route = useRoute()
const router = useRouter()

const isCollapse:ComputedRef<boolean> = computed(() => {
  return store.state.isCollapse
})
const handleChangeCollapse = () => {
  store.commit("changeIsCollapse")
}
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}


const handleExit = () => {
  router.push("/login")
}
</script>

<style lang="less" scoped>
.el-menu {
  height: 100vh;
}

h3 {
  cursor: pointer;
  color: #4D5259;
  text-align: center;
  line-height: 48px;
  font-size: 18px;
  font-weight: 700;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}

//:deep(.el-menu-item-group ) {
//  background-color: #001528 !important; // 设置展开后的背景颜色
//}

i {
  font-size: 16px !important;
}
</style>
